﻿using System;
using System.Web.Services;
using System.Web.UI.WebControls;
using BillBook.Controller;
using BillBook.Model;
using System.Collections.Generic;

public partial class admin_user_listusers : System.Web.UI.Page
{
    //protected void Page_Load(object sender, EventArgs e)
    //{
    //    UserController userController=new UserController();
    //    List<User> users = userController.ListUsers();
    //    TableRow tr1 = new TableRow();
    //    TableCell[] header = new TableCell[9];
    //    header[0] = new TableCell();
    //    header[1] = new TableCell();
    //    header[2] = new TableCell();
    //    header[3] = new TableCell();
    //    header[4] = new TableCell();
    //    header[5] = new TableCell();
    //    header[6] = new TableCell();
    //    header[7] = new TableCell();
    //    header[8] = new TableCell();

    //    header[0].Text = "UserID";
    //    header[1].Text = "UserName";
    //    header[2].Text = "Password";
    //    header[3].Text = "FirstName";
    //    header[4].Text = "LastName";
    //    header[5].Text = "IsActive";
    //    header[6].Text = "IsDeleted";
    //    header[7].Text = "Actions";
    //    header[8].Text = "Actions";

    //    tr1.Cells.AddRange(header);
    //    Table1.Rows.Add(tr1);

    //   foreach(User user in users)
    //    {
    //        TableRow tr = new TableRow();
    //        TableCell[] cells=new TableCell[9];
    //        cells[0]=new TableCell();
    //        cells[1] = new TableCell();
    //        cells[2] = new TableCell();
    //        cells[3] = new TableCell();
    //        cells[4] = new TableCell();
    //        cells[5] = new TableCell();
    //        cells[6] = new TableCell();
    //        cells[7] = new TableCell();
    //        cells[8] = new TableCell();

    //        cells[0].Text = user.UserID.ToString();
    //        cells[1].Text = user.UserName;
    //        cells[2].Text = user.Password;
    //        cells[3].Text = user.FirstName;
    //        cells[4].Text = user.LastName;
    //        cells[5].Text = user.IsActive.ToString();
    //        cells[6].Text = user.IsDeleted.ToString();
    //        cells[7].Text = user.Email;
    //        cells[8].Text = "<a href='edituser.aspx?id=" + user.UserID.ToString() + "'>Edit</a>";
    //        tr.Cells.AddRange(cells);

    //        Table1.Rows.Add(tr);
    //    }
    //}

    [WebMethod]
    public static List<User> getAllUsers(int startrecordno)
    {
        UserController userController = new UserController();
        List<User> users = userController.ListUsers(startrecordno, 3);
        return users;
    }

    [WebMethod]
    public static sbyte changeUserPassword(long userid, string password)
    {
        UserController userController = new UserController();
        return userController.ChangePassword(userid,password);
    }

    [WebMethod]
    public static int UserCount()
    {
        UserController userController = new UserController();
        return userController.Count();
    }
}
